import unittest
import ddt
import time
from selenium.webdriver.support.ui import Select
from Base.BaseSetings import *
from WoniuBossPOM.Student_Management_POM_PZY import Stu_Sys_Mamagement
from Business.HumanMangement_Sun import WoniuBoss
from Business.TeachingManagement_cx import TeachingManagementTest
from Business.Employ_Management_SHL import Employ_Management
from Business.ClassManagement_wxj import cls_management
from WoniuBossPOM.All_Management_POM import All_Mamagement
from Business.all import WoniuBoss


@ddt.ddt
class Us(unittest.TestCase):
    def setUp(self) -> None:
        # self.dr = All_Mamagement()
        # self.run = WoniuBoss()
        # self.TM = TeachingManagementTest()
        # self.ru = Employ_Management()
        # self.w = cls_management()
        self.dr = WoniuBoss()


    # def tearDownClass(cls) -> None:
    #     cls.dr.closeBroswer()


    def test_alterrole(self):  # 修改用户描述
        result = self.dr.alterrole()
        print(result)
        self.assertEqual(result,'我是班主任')

    @ddt.file_data(TestData_dir + "search_user.yaml")
    def test_search_user(self,**kwargs):  # 用户管理  用户查询
        result =self.dr.search_user()
        self.assertEqual(result, kwargs.get('assert_info'))


#-------------------------------------------------------------------------------------彭振宇

    @ddt.file_data(TestData_dir + 'human_mangement.yaml')
    def test_01(self, **kwargs):
        info = self.dr.human_mangement_creatstaff(kwargs)
        self.assertEqual(info[0][0],kwargs.get('assert_name'), '添加成功')
        self.assertEqual(info[1][0],kwargs.get('assert_name'), '添加成功')

    def test_02(self):
        info = self.dr.human_mangement_querystaff('全部', '全部', '全部', '张莉')
        self.assertEqual(info[0][0], '张莉', '查询成功')
#---------------------------------------------------------------------------------------孙冉

    @ddt.file_data(TestData_dir +'teaching_management.yaml')
    def test_case_add_apply(self,**kwargs):
        time.sleep(2)
        id,table2,selectText = self.dr.add_apply(kwargs.get('flag'))
        self.assertEqual(int(id)+1,int(table2[0][0]))
        for selected in selectText:
           self.assertEqual(selectText,table2[0][2])



    # def test_case_apply_reason(self):
    #     res = self.dr.apply_reason()
    #     self.assertEqual(res,'加班原因少于10字不能提交')


    def test_case_assign_work(self):
        tableInfo,selectedText = self.dr.assign_work()
        self.assertEqual(selectedText,tableInfo[0][1])


    def test_case_sys_employee_query(self):
        res = self.dr.sys_employee_query()
        self.assertEqual(res, eval("[['无符合条件的记录']]"))
#------------------------------------------------------------------------------------陈雪

    # @ddt.file_data(TestData_dir + "add_company.yaml")
    # def test_case_002(self, **kwargs):
    #     result = self.dr.add_company(kwargs.get("company"), kwargs.get("industry"), kwargs.get("address"),
    #                                  kwargs.get("name"), kwargs.get("phone"))
    #     print(result)
    #
    #     self.assertIn(kwargs.get("expect"), result[0])
    #
    # def test_case_003(self):
    #     result = self.dr.search_company("成都", "WNCDC_2901", "测试")
    #     print(result)
    #     for i in result:
    #         print(i)
    #         self.assertEqual(i[3], "测试")
    #
    # def test_case_004(self):
    #     result = self.dr.add_join_company("成都", "WNCDC_2901", "测试", "测试工程师", "15000", "阿里巴巴")
    #     print(result)
    #     for i in result:
    #         # print(i)
    #         a = (i[-1].split("\n")[-1])
    #         self.assertEqual(a, "提交新增")

    # def test_case_005(self):
    #     result = self.dr.search_company_client("阿里巴巴")
    #     print(result)
    #     self.assertEqual(result[0][0], "阿里巴巴")
    #
    # def test_case_006(self):
    #     result = self.dr.modification("阿里巴巴", "李小姐")
    #
    #     print(result)
    #     self.assertEqual(result[0][2], "李小姐")
#------------------------------------------------------------------------------舒慧玲

    # @ddt.file_data(TestData_dir + "stu_leave_select_wxj.yaml")
    # def test_stu_leave_select(self, **kwargs):  # 学员请假信息查询===
    #     # self.w.login('WNCD000','woniu123')
    #     info = self.dr.stu_leave_select(kwargs.get('region'), kwargs.get('status_leave'), kwargs.get('leave_stu_name'))
    #     print(info)
    #     self.assertEqual(info[0][0], kwargs.get('leave_stu_name'))
    #     self.assertEqual(info[0][9], kwargs.get('status_leave'))
    #     # self.w.login_out()
    #
    # @ddt.file_data(TestData_dir + "stu_change_wxj.yaml")
    # def test_stu_change(self, **kwargs):  # 学员转班===
    #     # self.w.login('WNCD000','woniu123')
    #     info = self.dr.stu_change(kwargs.get('school_region'), kwargs.get('change_cls'))
    #     print(info)
    #     self.assertEqual(info, kwargs.get('except'))
    #     # self.w.login_out()
    #
    # @ddt.file_data(TestData_dir + "stu_change_wxj.yaml")
    # def test_stu_change_query(self, **kwargs):  # 学员转班信息查询===
    #     # self.w.login('WNCD000','woniu123')
    #     infos = self.dr.stu_change_query(kwargs.get('school_region'), kwargs.get('change_cls'))
    #     for info in infos:
    #         print(info)
    #         if info != ['无符合条件的记录']:
    #             self.assertEqual(info[3], kwargs.get('change_cls'))
    #             # self.w.login_out()
    #
    # @ddt.file_data(TestData_dir + "cls_manage_wxj.yaml")
    # def test_cls_manage(self, **kwargs):  # 新增班级
    #     # self.w.login('WNCD000','woniu123')
    #     res = self.dr.cls_manage(kwargs.get('cls_num'), kwargs.get('direction'), kwargs.get('teacher'))
    #     print(res)
    #     self.assertEqual(res, kwargs.get('except'))
        # self.w.login_out()
        # time.sleep(2)

#------------------------------------------------------------------------------------吴小静
if __name__ == '__main__':
    unittest.main()